﻿#region Copyright (C) 2008, 2009 StreamTv

/* 
 *      Copyright (C) 2008, 2009 StreamTv
 *      http://code.google.com/p/mpstreamtv/
 *
 *  This Program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *   
 *  This Program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *   
 *  You should have received a copy of the GNU General Public License
 *  along with GNU Make; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
 *  http://www.gnu.org/copyleft/gpl.html
 *
 */

#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net.Sockets;

namespace TimeShifting.Media.Encoders.Transport
{
    public class UdpPipe : Stream
    {
        private Socket udpSocket;
        private NetworkStream udpStream;

        public UdpPipe()
        {
            throw new NotImplementedException("UDP Isn't ready yet.");

            udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Udp);

            udpStream = new NetworkStream(udpSocket, FileAccess.ReadWrite, true);
        }

        public override bool CanRead
        {
            get { return udpStream.CanRead; }
        }

        public override bool CanSeek
        {
            get { return udpStream.CanSeek; }
        }

        public override bool CanWrite
        {
            get { return udpStream.CanWrite; }
        }

        public override void Flush()
        {
            udpStream.Flush();
        }

        public override long Length
        {
            get { return udpStream.Length; }
        }

        public override long Position
        {
            get
            {
                return udpStream.Position;
            }
            set
            {
                udpStream.Position = value;
            }
        }

        public override int Read(byte[] buffer, int offset, int count)
        {
            return udpStream.Read(buffer, offset, count);
        }

        public override long Seek(long offset, SeekOrigin origin)
        {
            return udpStream.Seek(offset, origin);
        }

        public override void SetLength(long value)
        {
            udpStream.SetLength(value);
        }

        public override void Write(byte[] buffer, int offset, int count)
        {
            udpStream.Write(buffer, offset, count);
        }
    }
}
